<template>
	<view class="main">
		<view class="top-main">
			<view class="topSearch">
				<view class="date-left">
					<view class="date-item" @click="timeSelect('startTime')">
						<span class="date-tip" v-if="queryParams.startTime">{{queryParams.startTime}}</span>
						<span class="date-tip date-tip0" v-if="!queryParams.startTime">请选择</span>
						<u-icon name="arrow-down-fill" color="#111111" size="10"></u-icon>
					</view>
					<span class="date-snap">至</span>
					<view class="date-item" @click="timeSelect('endTime')">
						<span class="date-tip" v-if="queryParams.endTime">{{queryParams.endTime}}</span>
						<span class="date-tip date-tip0" v-if="!queryParams.endTime">请选择</span>
						<u-icon name="arrow-down-fill" color="#111111" size="10"></u-icon>
					</view>
				</view>
				<view class="date-right">
					<view @click="dateSwitch" class="data-btn" :class="[isDateDay?'':'data-btn2']">月份</view>
					<view @click="getAll" class="data-btn data-btn2">全部</view>
				</view>
			</view>
			<view class="inputSaech">
				<view class="data-btn data-btn3" @click="download">导出</view>
			</view>
			<view class="top-summary">
				<span class="top-summary-name">柯未来</span>
				<span>总工时：52个工</span>
			</view>
		</view>
		
		
	
		<!--list-satrt -->
		<view class="list">
			<view class="item" v-for="item in 6">
				<view class="item-top">2023.12.06</view>
				<view class="item-right">
					<view class="item-name">
						<view class="item-name-left">
							<span class="item-name-tip">柯未来</span>
						</view>
						<view class="item-name-right">
							工时：1个工
						</view>
					</view>
					
				</view>

			</view>
		</view>
		<!--list-end -->


		<view class="list-end" v-if="dataList.length">{{endText}}</view>

		<u-empty v-if="!dataList.length" mode="car" text="暂无数据" icon="/static/empty-img.png">
		</u-empty>
		
		<u-datetime-picker :show="showinTime" :value="inTime" :mode="isDateDay?'date':'year-month'" closeOnClickOverlay @confirm="TimeConfirm"
			@cancel="TimeClose" @close="TimeClose"></u-datetime-picker>
		

	</view>
</template>

<script>
	import props from './date-props.js';
	import db from '@/common/localstorage.js'
	export default {
		mixins: [props],
		data() {
			return {
				isDateDay:true,
				timeType: '',
				showinTime:false,
				inTime: Number(new Date()),
				queryParams: {
					startTime:'',
					endTime:'',
					pageNo: 1,
					pageSize: 10
				},
				total: 0,
				endText: '',
				dataList: []

			}
		},
		onLoad() {
			// this.userInfo = db.get('userInfo')
		},
		onShow() {
			this.queryParams.pageNo = 1
			this.dataList = []

		},
		methods: {
			dateSwitch(){
				this.isDateDay = !this.isDateDay
				this.queryParams.startTime = ''
				this.queryParams.endTime = ''
			},
			download(){},
			onSearch(){},
			getAll(){},
			getList() {
				this.$modal.msgLoading('加载中')

				var that = this
				let url = this.queryParams.flag == 1 ? '/app-api/proj/major-projects/page' :
					'/app-api/proj/dpk/m-simple-list'
				this.$get(url, this.queryParams).then(res => {
					uni.hideLoading()
					if (res.data.code == 0) {
						let detail = res.data.data.list

						if (detail.length < that.queryParams.pageSize) {
							that.endText = '没有更多了'
						}
						that.total = res.data.data.total
						that.dataList = that.dataList.concat(detail)
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},



			toDetail(id) {
				uni.navigateTo({
					url: '/pagesMain/other/workload/detail'
				})
			},


		},

		onReachBottom: function(e) {
			if (this.total > this.dataList.length) {
				(this.queryParams.pageNo) ++;
				this.getList()
			}
		},
	}
</script>

<style lang="scss" scoped>
	.top-main {
		background-color: #fff;
		padding-top: 32upx;
		padding-bottom: 40upx;
		padding-left: 24upx;
		padding-right: 24upx;
		margin-bottom: 30upx;
	
		.topSearch {
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
		.inputSearch-left{
			width: calc(100% - 114upx);
		}
		.date-left {
			display: flex;
			align-items: center;
		}
	
		.date-right {
			display: flex;
			align-items: center;
		}
	
		.date-item {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 32rpx;
			color: #111111;
			display: flex;
			align-items: center;
			width: 188rpx;
		}
	
		.date-tip {
			width: 168rpx;
			display: inline-block;
			margin-right: 4upx;
			text-align: center;
		}
	
		.date-tip0 {
			font-weight: normal;
			color: #999;
			font-size: 28rpx;
		}
	
		.date-snap {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #111111;
			margin: 0 10upx;
		}
	
		.data-btn {
			width: 94rpx;
			height: 58rpx;
			background: rgba(17, 170, 102, 0.1);
			border-radius: 10rpx;
			border: 2rpx solid #11AA66;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #11AA66;
			line-height: 58rpx;
			margin-left: 20upx;
			text-align: center;
		}
	
		.data-btn2 {
			background: #11AA66;
			color: #FFFFFF;
		}
		.data-btn3{
			background: #11AA66;
			color: #FFFFFF;
			margin-left: auto;
			margin-top: 24upx;
		}
	
		.inputSaech {
			width: 100%;
			flex: 0 0 100%;
			display: flex;
			align-items: center;
			border-bottom: 1rpx solid #E4E4E4;
			padding-bottom: 16upx;
		}
		.top-summary{
			height: 90rpx;
			background: rgba(17,170,102,0.1);
			border-radius: 10rpx;
			line-height: 90rpx;
			margin-top: 20upx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #111111;
			.top-summary-name{
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 32rpx;
				color: #111111;
				margin-right: 136upx;
				margin-left:20upx ;
			}
		}
	}
	
	page {
		background: #F9F9F9;
	}

	.main {
		padding: 0;
		padding-bottom: 260upx;
	}
	
	

	.list {
		padding: 0 24upx;
		width: calc(100% - 48upx);

		.item {
			margin-bottom: 30upx;
			.item-top{
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 32rpx;
				color: #111111;
				margin-bottom: 20upx;
				
			}
			.item-right {
				width: calc(100% - 56upx);
				position: relative;
					background: #FFFFFF;
					padding: 30upx 28upx;
					border-radius: 10rpx;

				.item-name {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
					display: flex;
					justify-content: space-between;
					align-items: center;
				}
				.item-name-left{
					display: flex;
					align-items: center;
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #111111;
					
				}
				.tem-name-right{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
				}
				

				



			}


		}

	}

</style>